package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-04-18 21:23
 */
public class Q11 {
    public int maxArea(int[] height) {
        if(height == null || height.length <= 1) {
            return 0;
        }

        int i = 0, j = height.length - 1;
        int res = 0;
        while(i < j) {
            res = Math.max(res, Math.min(height[i], height[j]) * (j - i));
            if(height[i] <= height[j]) {
                i++;
            } else {
                j--;
            }
        }

        return res;
    }
}
